package com.ycp.erp.main.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jakewharton.rxbinding2.view.RxView;
import com.one.common.config.RouterPath;
import com.one.common.manager.RouterManager;
import com.one.common.view.base.BaseActivity;
import com.one.common.view.widget.MyTitleBar;
import com.ycp.erp.R;
import com.ycp.erp.login.activity.LoginErpActivity;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;

/**
 * Class Des:系统设置
 * Created by bjh on 2021/9/3.
 */
@Route(path = RouterPath.SETTING)
public class SettingActivity extends BaseActivity {
    @BindView(R.id.rlMyInfo)
    RelativeLayout rlMyInfo;
    @BindView(R.id.rlModifyPsw)
    RelativeLayout rlModifyPsw;
    @BindView(R.id.rlPrivacyAuthority)
    RelativeLayout rlPrivacyAuthority;
    @BindView(R.id.rlVersion)
    RelativeLayout rlVersion;
    @BindView(R.id.rlCatch)
    RelativeLayout rlCatch;
    @BindView(R.id.rlShare)
    RelativeLayout rlShare;
    @BindView(R.id.rlContactCustomerService)
    RelativeLayout rlContactCustomerService;
    @BindView(R.id.rlFeedback)
    RelativeLayout rlFeedback;
    @BindView(R.id.rlPrintTemplate)
    RelativeLayout rlPrintTemplate;
    @BindView(R.id.tvLoginOut)
    TextView tvLoginOut;

    @Override
    protected void initPresenter() {

    }

    @SuppressLint("CheckResult")
    @Override
    public void initView() {
        super.initView();
        RxView.clicks(tvLoginOut).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //退出登录
            Intent loginActivityIntent = new Intent();
            loginActivityIntent.setClass(mContext, LoginErpActivity.class);
            loginActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(loginActivityIntent);
        });
        RxView.clicks(rlMyInfo).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //我的资料
            RouterManager.getInstance().go(RouterPath.PERSONAL_INFO);
        });
        RxView.clicks(rlModifyPsw).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //修改密码
            RouterManager.getInstance().go(RouterPath.MODIFY_PSW);
        });
        RxView.clicks(rlPrivacyAuthority).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //隐私权限

        });

        RxView.clicks(rlPrintTemplate).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //打印模板

        });
        RxView.clicks(rlVersion).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //当前版本

        });
        RxView.clicks(rlShare).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //推荐分享

        });
        RxView.clicks(rlContactCustomerService).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //联系客服

        });
        RxView.clicks(rlFeedback).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            //意见反馈

        });
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("系统设置").hideLine();
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_setting;
    }
}
